package {
	import fastas3.FastObject;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class fastas3test extends Sprite
	{
		
		public function fastas3test()
		{
			$(stage);
			
			for (var i:int = 0; i < 10; i++) {
				var sprite:Sprite = new Sprite();
				sprite.name = "test" + (i+1);
				sprite.graphics.beginFill(0x996600);
				sprite.graphics.drawRect(0,0,30,30);
				sprite.graphics.endFill();
				sprite.x = i * 50;
				addChild(sprite);
				
				var sprite2:Sprite = new Sprite();
				sprite2.name = "testtest" + (i+1);
				sprite2.graphics.beginFill(0x660099);
				sprite2.graphics.drawRect(0,0,10,10);
				sprite2.graphics.endFill();
				sprite.addChild(sprite2);
				
				var sprite3:Sprite = new Sprite();
				sprite3.name = " testtesttest" + (i+1);
				sprite3.graphics.beginFill(0x006699);
				sprite3.graphics.drawRect(0,0,10,10);
				sprite3.graphics.endFill();
				sprite3.x = 20;
				sprite.addChild(sprite3);
				
				var sprite4:Sprite = new Sprite();
				sprite4.name = "tete" + (i+1);
				sprite4.graphics.beginFill(0x000000);
				sprite4.graphics.drawRect(0,0,5,5);
				sprite4.graphics.endFill();
				sprite4.x = 5;
				sprite4.y = 5;
				sprite3.addChild(sprite4);
			}
			
			// plugin
			FastObject.prototype.addX = function(value:Number):FastObject {
				this.add("x", value);
				return this;
			};
			
			/*
			$("Sprite#tes*").click(function(e:MouseEvent):void {
				//$(e.currentTarget).add("x", 20);
				$(e.currentTarget).addX(20);
			});
			*/
			/*
			$("#test*").tween(
				1,
				{
					x: 150
				}
			);
			*/
			
			$("#test*").tweenWith(
				2,
				function (o:DisplayObject):Object {
					return {
						x: o.x + 30
					};
				}
			);
			
			$("Sprite#test1 Sprite").click(
				function(e:MouseEvent):void {
					$(e.currentTarget).add("y", 20);
				}
			);

			$("#test1").click(function(e:MouseEvent):void {
				trace("TEST1 CLICKED");
			});
		}

	}
}
